package com.five.monkey.swagger.starter.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 狻猊
 * @date 2021/11/8 2:45 下午
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /*
    目前springboot有两种使用swagger的方式
    1、引入swagger原生依赖springfox-swagger2和springfox-swagger2-ui
    原生依赖是通过java config类来配置
    2、引入国内Spring4All社区开发的依赖swagger-spring-boot-starter
    Spring4All开发的依赖采取配置文件的方式进行配置
     */
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
    }
}
